package com.yonyou.pmclouds.plan.processor;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.plan.entity.ProjectPlanVO;

public class PlanLevelCheck implements SingleProcessor<ProjectPlanVO> {
    public static final int MAX_LEVEL = 20;

    @Override
    public void process(ProjectPlanVO vo, ProjectPlanVO orig) throws BusinessException {
        String code = vo.getScode();
        int level = 1;
        for (int i = 0; i < code.length(); i++) {
            if (code.charAt(i) == '.') {
                level++;
            }
        }
        if (level > MAX_LEVEL) {
            throw new BusinessException("计划超过最大层级限制！");
        }
    }
}
